package cn.xenoscode.simplepool.config;

import cn.xenoscode.simplepool.mqtt.SimpleMqttPool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Xenos
 * @version V1.0
 * @Package xenoscode.cn.mqttpool.config
 * @date 2020/9/1 16:44
 */

@Configuration
public class MqttClientPoolConfiguration {
    @Value("${mqtt.host}")
    private String host;
    @Autowired
    private SimpleMqttClientProperties simpleMqttClientProperties;
    @Autowired
    private SimpleMqttPoolProperties simpleMqttPoolProperties;

    @Bean("mqttPool")
    public SimpleMqttPool mqttPool() {
        SimpleMqttPool simpleMqttPool = new SimpleMqttPool(simpleMqttPoolProperties.getMinPoolSize(),
                simpleMqttPoolProperties.getMaxPoolSize(),
                simpleMqttPoolProperties.getOverseeInterval(),
                host,
                simpleMqttClientProperties);
        return simpleMqttPool;
    }

}
